﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Engine;
namespace Playtime
{
    public enum GameState
    {
        Editor,
        Menu,
        Game
    }
    public class GameStateManager : DrawableGameComponent
    {
        static GameState CurrentState;
        static UIScreen currentScreen;

        public GameStateManager(Game _game) : base(_game)
        {
            
        }

        public static void LoadEditor()
        {
            SceneManager.Reset();
            CurrentState = GameState.Editor;
            GameObject.Initialize("Level", Vector2.Zero, new Dictionary<Type, object[]>()
            {
                {typeof(LevelEditor), new object[]{}}
            });
            currentScreen = null;
            SceneManager.LoadLevel();
        }

        public static void LoadGame(LevelData _data)
        {
            CurrentState = GameState.Game;
            //SceneManager.Reset();
            GameObject.Initialize("World", Vector2.Zero, new Dictionary<Type, object[]>()
            {
                {typeof(World), new object[]{_data}}
            });
            SceneManager.LoadLevel();
        }

        public static void LoadMenu()
        {
            CurrentState = GameState.Menu;
            SceneManager.Reset();
            currentScreen = new MenuScreen();
        }

        public override void Update(GameTime gameTime)
        {
            if(currentScreen != null)
                currentScreen.Update(gameTime);
            if (currentScreen != null)
                currentScreen.Draw();
            base.Update(gameTime);
        }
    }
}
